package com.object.module.cbb.controller;

import com.object.configuration.utils.PageUtils;
import com.object.configuration.utils.Q;
import com.object.module.cbb.entity.CbbAddressEntity;
import com.object.module.cbb.service.CbbAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 用户地址
 *
 * @author 小🌤
 * @email 1578442339@qq.com
 * @date 2022-03-30 16:29:15
 */
@RestController
@RequestMapping("/cbb/cbbaddress")
public class CbbAddressController {
    @Autowired
    private CbbAddressService cbbAddressService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Q list(@RequestParam Map<String, Object> params) {
        PageUtils page = cbbAddressService.queryPage(params);
        return Q.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{adId}")
    public Q info(@PathVariable("adId") Integer adId) {
            CbbAddressEntity cbbAddress = cbbAddressService.info(adId);
            return Q.ok().put("cbbAddress", cbbAddress);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Q save(@RequestBody CbbAddressEntity cbbAddress) {
            cbbAddressService.save(cbbAddress);
            return Q.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Q update(@RequestBody CbbAddressEntity cbbAddress) {
            cbbAddressService.updateById(cbbAddress);
            return Q.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Q delete(@RequestBody Integer[] adIds) {
            cbbAddressService.removeByIds(Arrays.asList(adIds));
            return Q.ok();
    }

}
